﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Eleanor.BLL;
using System.Dynamic;

namespace Eleanor.Website.Utility.Filter
{
    public class SharedDataFilter : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            ControllerBase controller = filterContext.Controller;
            if ("Eleanor.Website.Controllers".Equals(controller.GetType().Namespace, StringComparison.OrdinalIgnoreCase))
            {
                SubjectBLL subjectBLL = new SubjectBLL();
                PaintingBLL paintingBLL = new PaintingBLL();

                controller.ViewBag.SubjectList = subjectBLL.GetAll();
                controller.ViewBag.Website = new ExpandoObject();
                controller.ViewBag.Website.Domain = SettingBLL.Instance.GetWebsiteDomain();
                controller.ViewBag.GACode = SettingBLL.Instance.GetGACode();
            }
        }
    }
}